//
//  netWork.m
//  Advertisement
//
//  Created by mac on 16/4/18.
//  Copyright © 2016年 Appcoda. All rights reserved.
//

#import "netWork.h"
#import "MAin.h"
@implementation netWork
//第三和第四页面
+(void)scroll:(void (^)(NSArray *arr))complete type:(NSString *)string
{
    AFHTTPRequestOperationManager *manager =[[AFHTTPRequestOperationManager alloc]init];
    manager.responseSerializer =[AFHTTPResponseSerializer serializer];
    NSString * str = [NSString stringWithFormat:@"http://47.88.76.185:8080/Test/%@",string];
    //http://47.88.19.232:8080/Test/%@
    [manager GET:str parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSMutableArray * newsArr = [[NSMutableArray alloc]init];
        NSDictionary *dic =[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSMutableArray * new = [dic objectForKey:@"pageData"];
        for (NSDictionary * d in new)
        {
            MAin * main = [[MAin alloc]init];
            main.name = [d objectForKey:@"name"];
            main.ID = [d objectForKey:@"id"];
            main.Imagelogo = [d objectForKey:@"logo"];
            main.fatherid = [d objectForKey:@"fatherid"];
            main.image = [d objectForKey:@"image"];
            [newsArr addObject:main];
        }
        if (complete) {
            complete(newsArr);
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error)
     {
         NSLog(@"失败了%@",error);
     }];
}
//
+(void)ZhuCe:(void (^)(NSArray *arr))complete ;
{
//    AFHTTPRequestOperationManager * manger = [[AFHTTPRequestOperationManager alloc]init];
//    manger.responseSerializer =[AFHTTPResponseSerializer serializer];//192.168.0.105
//    [manger POST:@"http://192.168.0.105:8080/Test/app_addUser" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
//        
////        NSData *data =UIImageJPEGRepresentation(img, 0);
//        [formData appendPartWithFileData:imageData name:aKeyName fileName:fileName mimeType:(__bridge NSString *)(MIMEType)];
//        [formData appendPartWithFormData:@"data数据" name:@"logo"];
//        NSString *filePath =[[NSBundle mainBundle]pathForResource:@"你是我的眼" ofType:@"mp3"];
//        [formData appendPartWithFileData:nil name:nil fileName:filePath mimeType:@"mp3"];
//        
//        
//        NSLog(@"1-----");
//    } success:^(AFHTTPRequestOperation *operation, id responseObject) {
//        NSLog(@"2 成功------");
//    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//        NSLog(@"3失败-----");
//    }];
    
}


@end
